package org.kukker.spinner;

import java.util.Map;

import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.widget.Spinner;

public class KukkerSpinner extends Spinner {

	public KukkerSpinner(Context context, AttributeSet attrs, Map inflateParams) {
		super(context, attrs, inflateParams);
		Log.i("debug","KukkerSpinner");
		
	}
		
	private String debugtag = "eventflow3";
	
	public boolean onTouchEvent(MotionEvent event){
		String actionName = org.kukker.Util.kMotionEvent.getActionName(event);
		Log.i(debugtag,
	    			"["+this.getClass().getSimpleName()+"]" +
	    			
	    			"["+
	    			"isSelected:"+this.isSelected()+
	    			"]"
	    			
	    			+"["
	    			+"onTouchEvent()"
	    			
	    			+", action:"+actionName
	    			+"]"
	    			
			 );
		return false;
	}
	
	
	public boolean onKeyUp(int keyCode, KeyEvent event){
			Log.i(debugtag,
   			"["+this.getClass().getSimpleName()+"]" +
   			
   			"["+
   			"isSelected:"+this.isSelected()+
   			"]"
   			
   			+"["
   			+"onKeyUp() " +
   			",keyCode:"+keyCode
   			
   			+"]"    			
   	);
		
		if(keyCode == KeyEvent.KEYCODE_DPAD_LEFT){
			this.setSelection(this.mSelectedPosition--);	
		}else if(keyCode == KeyEvent.KEYCODE_DPAD_RIGHT){
			this.setSelection(this.mSelectedPosition++);
		}
		
			
		return true;
	}
	
	public boolean onKeyDown(int keyCode, KeyEvent event){
			
		Log.i(debugtag,
   			"["+this.getClass().getSimpleName()+"]" +
   			
   			"["+
   			"isSelected:"+this.isSelected()+
   			"]"
   			
   			+"["
   			+"onKeyDown() " +
   			",keyCode:"+keyCode
   			
   			+"]"    			
		);
		
		return true;
	}
	
	 public void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect){
		 Log.i(	debugtag,
				  "[" + this.getClass().getSimpleName() + "]" 
				 +"[" + "isSelected:" + this.isSelected() + "]"
				 +"[" + "onFocusChanged()" + ", gainFocus:" + gainFocus
				 +", direction:" + direction + "]"

		);
		  	if(gainFocus){
		  		
		  	}else{
		  		
		  		
		  	}
		
	}
	
	
}